package mybox.engine.fresnel;

import static java.lang.Math.PI;
import static java.lang.Math.*;

public class AngleHelper {
	public static double absoluteRad(double x, double y) {
		return absoluteRad(java.lang.Math.atan2(y, x));
	}
	
	public static double absoluteRad(double radAngle) {
		while(radAngle<0) {			
			radAngle += 2*PI;
		}		
		while (radAngle>=2*PI) {			
			radAngle -= 2*PI;
		}		
		return radAngle;
	}
	
	public static double relativeRad(double radAngle) {
		while(radAngle<-PI) {			
			radAngle += 2*PI;
		}		
		while (radAngle>=PI) {			
			radAngle -= 2*PI;
		}		
		return radAngle;
	}
	
	public static boolean angleIsBetween(double radAngle1, double radAngle2, double testAngle) {
		
		double one2Testd=abs(radAngle1-testAngle);
		double two2Testd=abs(radAngle2-testAngle);
		double one2Twod=abs(radAngle1-radAngle2);		
		return one2Testd+two2Testd<=one2Twod;
	}
}
